<?php declare(strict_types=1);

namespace shali\ydb\think2fa\model;

use think\Model;

class Agent2Fa extends Model
{
    protected $table = 'tl_agent_2fa';

    const STATUS_DISABLE = 0;

    const STATUS_ENABLE = 1;

    public static function findByAgentNo(string $agentNo): ?Agent2Fa
    {
        return self::where('agent_no', $agentNo)->find();
    }

    public static function updateStatusByAgentNo(string $agentNo, int $status): int
    {
        return self::where('agent_no', $agentNo)->update(['status' => $status]);
    }

    public static function updateSecretByAgentNo(string $agentNo, string $secret): int
    {
        return self::where('agent_no', $agentNo)->update(['secret' => $secret]);
    }
}
